/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "sucursal", catalog = "bd_subway", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sucursal.findAll", query = "SELECT s FROM Sucursal s"),
    @NamedQuery(name = "Sucursal.findBySucId", query = "SELECT s FROM Sucursal s WHERE s.sucId = :sucId"),
    @NamedQuery(name = "Sucursal.findBySucNombre", query = "SELECT s FROM Sucursal s WHERE s.sucNombre = :sucNombre"),
    @NamedQuery(name = "Sucursal.findBySucCiudad", query = "SELECT s FROM Sucursal s WHERE s.sucCiudad = :sucCiudad")})
public class Sucursal implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "sucId")
    private Integer sucId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "sucNombre", nullable = false, length = 30)
    private String sucNombre;
    @Size(max = 30)
    @Column(name = "sucCiudad", length = 30)
    private String sucCiudad;
    @JoinColumn(name = "sucPaisId", referencedColumnName = "paisId", nullable = false)
    @ManyToOne(optional = false)
    private CatPais sucPaisId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "empSucursalId")
    private List<Empleado> empleadoList;

    public Sucursal() {
    }

    public Sucursal(Integer sucId) {
        this.sucId = sucId;
    }

    public Sucursal(Integer sucId, String sucNombre) {
        this.sucId = sucId;
        this.sucNombre = sucNombre;
    }

    public Integer getSucId() {
        return sucId;
    }

    public void setSucId(Integer sucId) {
        this.sucId = sucId;
    }

    public String getSucNombre() {
        return sucNombre;
    }

    public void setSucNombre(String sucNombre) {
        this.sucNombre = sucNombre;
    }

    public String getSucCiudad() {
        return sucCiudad;
    }

    public void setSucCiudad(String sucCiudad) {
        this.sucCiudad = sucCiudad;
    }

    public CatPais getSucPaisId() {
        return sucPaisId;
    }

    public void setSucPaisId(CatPais sucPaisId) {
        this.sucPaisId = sucPaisId;
    }

    @XmlTransient
    public List<Empleado> getEmpleadoList() {
        return empleadoList;
    }

    public void setEmpleadoList(List<Empleado> empleadoList) {
        this.empleadoList = empleadoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sucId != null ? sucId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sucursal)) {
            return false;
        }
        Sucursal other = (Sucursal) object;
        if ((this.sucId == null && other.sucId != null) || (this.sucId != null && !this.sucId.equals(other.sucId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.sucNombre;
    }
    
}
